import java.io.*;
/** 复制文件
 * 
 */
public class FileCopy{
	public static void main(String[] args) {
		String sfilepath = "./1.txt";
		String dfilepath = "./2.txt";

		File sfile = new File(sfilepath);
		File dfile = new File(dfilepath);

		try{
			dfile.createNewFile();
			FileInputStream fin = new FileInputStream(sfile);
			FileOutputStream fout = new FileOutputStream(dfile);
			byte[] tmp = new byte[512];
			int rs = -1;
			while((rs = fin.read(tmp) )> 0 ){
				fout.write(tmp,0,rs);
			}
			fin.close();
			fout.close();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}